package com.ruoyi.park.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.park.mapper.BuiBuildingControlMapper;
import com.ruoyi.park.domain.BuiBuildingControl;
import com.ruoyi.park.service.IBuiBuildingControlService;

/**
 * 楼栋自控Service业务层处理
 *
 * @author cjie
 * @date 2021-07-20
 */
@Service
public class BuiBuildingControlServiceImpl implements IBuiBuildingControlService {
    @Autowired
    private BuiBuildingControlMapper buiBuildingControlMapper;

    /**
     * 查询楼栋自控
     *
     * @param id 楼栋自控ID
     * @return 楼栋自控
     */
    @Override
    public BuiBuildingControl selectBuiBuildingControlById(String id) {
        return buiBuildingControlMapper.selectBuiBuildingControlById(id);
    }

    /**
     * 查询楼栋自控列表
     *
     * @param buiBuildingControl 楼栋自控
     * @return 楼栋自控
     */
    @Override
    public List<BuiBuildingControl> selectBuiBuildingControlList(BuiBuildingControl buiBuildingControl) {
        return buiBuildingControlMapper.selectBuiBuildingControlList(buiBuildingControl);
    }

    /**
     * 新增楼栋自控
     *
     * @param buiBuildingControl 楼栋自控
     * @return 结果
     */
    @Override
    public int insertBuiBuildingControl(BuiBuildingControl buiBuildingControl) {
        buiBuildingControl.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        buiBuildingControl.setCreateTime(DateUtils.getNowDate());
        buiBuildingControl.setCreateBy(SecurityUtils.getUsername());
        return buiBuildingControlMapper.insertBuiBuildingControl(buiBuildingControl);
    }

    /**
     * 修改楼栋自控
     *
     * @param buiBuildingControl 楼栋自控
     * @return 结果
     */
    @Override
    public int updateBuiBuildingControl(BuiBuildingControl buiBuildingControl) {
        buiBuildingControl.setUpdateTime(DateUtils.getNowDate());
        buiBuildingControl.setUpdateBy(SecurityUtils.getUsername());
        return buiBuildingControlMapper.updateBuiBuildingControl(buiBuildingControl);
    }

    /**
     * 批量删除楼栋自控
     *
     * @param ids 需要删除的楼栋自控ID
     * @return 结果
     */
    @Override
    public int deleteBuiBuildingControlByIds(String[] ids) {
        return buiBuildingControlMapper.deleteBuiBuildingControlByIds(ids);
    }

    /**
     * 删除楼栋自控信息
     *
     * @param id 楼栋自控ID
     * @return 结果
     */
    @Override
    public int deleteBuiBuildingControlById(String id) {
        return buiBuildingControlMapper.deleteBuiBuildingControlById(id);
    }
}
